package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;

import com.heima.model.wemedia.dtos.NewsAuthDto;

import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import com.heima.wemedia.service.impl.WmTaskServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2022/11/10 10:53
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService newsService;

    @Autowired
    private WmTaskServiceImpl service;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto reqDto){

        return newsService.list(reqDto);
    }

    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto newsDto) {

        return newsService.submit(newsDto);
    }

    //文章审核查询
    @PostMapping("/list_vo")
    public ResponseResult listVo(@RequestBody NewsAuthDto dto){
        return newsService.listVo(dto);
    }
    //w文章详情
    @GetMapping("/one_vo/{id}")
    public ResponseResult OneVOById(@PathVariable("id") Long id){
        return ResponseResult.okResult(newsService.getById(id));
    }
    //审核失败
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        return  newsService.fail(dto);
    }
    //审核通过
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
        return  newsService.pass(dto);
    }


    @GetMapping("/exec")
    public String test(){
        service.delayTaskExec();
        return "OK";
    }

}